#/bin/bash

APP_DIR=/www/python/host/
nginx=/usr/local/nginx/sbin/nginx
lockfile=/var/lock/subsys/nginx
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
prog=$(basename $nginx)

nginx_start() {
	echo "Starting $prog..."
	$nginx -s stop>/dev/null 2>&1
	$nginx -c $NGINX_CONF_FILE
}

uwsgi_start() {
	echo "Starting UWSGI..."
	if [ -f "/tmp/uwsgi.pid" ]; then
		uwsgi --stop /tmp/uwsgi.pid >/dev/null 2>&1
		rm -f /tmp/uwsgi.pid
	fi
	nohup uwsgi --ini ${APP_DIR}config.ini --pidfile /tmp/uwsgi.pid >/dev/null 2>&1 & #load app config
}

nginx_start
uwsgi_start
